<template>
  <div class="app-container">

    <div class="search-div">
      <el-form label-width="70px" size="small">
        <el-row>
          <el-col :span="8">
            <el-form-item label="关 键 字">
              <el-input style="width: 95%" v-model="searchObj.keyword" placeholder=""></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="操作时间">
              <el-date-picker v-model="createTimes" type="datetimerange" range-separator="至" start-placeholder="开始时间"
                end-placeholder="结束时间" value-format="yyyy-MM-dd HH:mm:ss" style="margin-right: 10px;width: 100%;" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row style="display:flex">
          <el-button type="primary" icon="el-icon-search" size="mini" @click="fetchData()">搜索</el-button>
          <el-button icon="el-icon-refresh" size="mini" @click="resetData">重置</el-button>
        </el-row>
      </el-form>
    </div>

    <!-- 列表 -->
    <el-table v-loading="listLoading" :data="list" stripe border style="width: 100%;margin-top: 10px;">

      +


      <el-table-column prop="id" label="实名认证ID" width="180" />
      <el-table-column prop="realname" label="真实姓名" width="110" />
      <el-table-column prop="sex" label="性别">
        <template slot-scope="scope">
          {{ scope.row.sex === 0 ? "女" : "男" }}
        </template>
      </el-table-column>
      <el-table-column prop="birthdate" label="出生日期" width="180" />
      <el-table-column prop="idnumber" label="身份证号" width="180" />
      <el-table-column prop="address" label="地址" width="180" />
      <el-table-column prop="state" label="状态" width="180" />
      <!-- <el-table-column prop="image1" label="照片1" width="180" /> -->
      <el-table-column prop="image1" label="照片1">
        <template slot-scope="scope">
          <viewer>
            <img :src="scope.row.image1" alt="" style="height: 80px" />
          </viewer>
        </template>
      </el-table-column>

      <!-- <el-table-column prop="image2" label="照片2" width="180" /> -->
      <el-table-column prop="image2" label="照片2">
        <template slot-scope="scope">
          <viewer>
            <img :src="scope.row.image2" alt="" style="height: 80px" />
          </viewer>
        </template>
      </el-table-column>

      <el-table-column prop="remark" label="备注" width="180" />
      <el-table-column prop="audittime" label="审核时间" width="180" />
      <el-table-column prop="applytime" label="申请时间" width="180" />
      <el-table-column prop="auditorId" label="审核人ID" width="180" />
      <el-table-column prop="applierId" label="申请人ID" width="180" />


      <el-table-column label="操作" align="center" fixed="right">
        <template slot-scope="scope">
          <el-button type="primary" icon="el-icon-edit" size="mini" @click="checkInfo(scope.row.id)" title="查看账户" />
          <!-- <el-button type="danger" icon="el-icon-delete" size="mini" @click="removeDataById(scope.row.id)" title="删除" /> -->
        </template>
      </el-table-column>
    </el-table>

    <!-- 分页组件 -->
    <el-pagination :current-page="page" :total="total" :page-size="limit" style="padding: 30px 0; text-align: center;"
      layout="total, prev, pager, next, jumper" @current-change="fetchData" />


    <el-dialog title="查看申请信息" :visible.sync="dialogVisible" width="40%">
      <el-form ref="dataForm" :model="loanList" label-width="100px" size="small" style="padding-right: 40px">
        <el-form-item label="认证ID" prop="id">
          <el-input v-model="loanList.id" :readonly="true" />
        </el-form-item>
        <el-form-item label="真实姓名" prop="realname">
          <el-input v-model="loanList.realname" :readonly="true" />
        </el-form-item>
        <el-form-item label="出生日期" prop="birthdate">
          <el-input v-model="loanList.birthdate" :readonly="true" />
        </el-form-item>
        <el-form-item label="身份证号" prop="idnumber">
          <el-input v-model="loanList.idnumber" :readonly="true" />
        </el-form-item>
        <el-form-item label="联系地址" prop="address">
          <el-input v-model="loanList.address" :readonly="true" />
        </el-form-item>
        <el-form-item label="状态" prop="state">
          <el-input v-model="loanList.state" :readonly="true" />
        </el-form-item>
        <el-form-item label="照片1" prop="image1">
  <img :src="loanList.image1" style="pointer-events: none; max-width: 150px; max-height: 150px;" />
</el-form-item>
<el-form-item label="照片2" prop="image2">
  <img :src="loanList.image2" style="pointer-events: none; max-width: 150px; max-height: 150px;" />
</el-form-item>


        <el-form-item label="备注" prop="remark">
          <el-input v-model="loanList.remark" :readonly="true" />
        </el-form-item>
        <el-form-item label="审核时间" prop="audittime">
          <el-input v-model="loanList.audittime" :readonly="true" />
        </el-form-item>
        <el-form-item label="申请时间" prop="applytime">
          <el-input v-model="loanList.applytime" :readonly="true" />
        </el-form-item>
        <el-form-item label="审核人id" prop="auditorId">
          <el-input v-model="loanList.auditorId" :readonly="true" />
        </el-form-item>
        <el-form-item label="申请人id" prop="applierId">
          <el-input v-model="loanList.applierId" :readonly="true" />
        </el-form-item>

      </el-form>

      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false" size="small" icon="el-icon-refresh-right">取 消</el-button>
        <el-button type="primary" icon="el-icon-check" @click="Approved()" size="small">通 过</el-button>
      </span>
    </el-dialog>

  </div>
</template>
  
<script>
import api from "@/api/realauth/realauth.js"
import { Image } from "element-ui";
export default {
  data() {
    return {
      listLoading: false, // 数据是否正在加载
      list: [], // banner列表
      total: 0, // 数据库中的总记录数
      page: 1, // 默认页码
      limit: 5, // 每页记录数
      searchObj: {}, // 查询表单对象
      // 处理时间范围条件的
      createTimes: [],
      dialogVisible: false,
      loanList: {},
      saveBtnDisabled: false,
      dialogRoleVisible: false,
      allRoles: [], // 所有角色列表
      userRoleIds: [], // 用户的角色ID的列表
      isIndeterminate: false, // 是否是不确定的
      checkAll: false // 是否全选
    };
  },
  created() {
    this.fetchData();
  },
  methods: {
    Approved() {
      api.Approved(this.loanList).then(() => {
        this.$message({
          message: "身份审核已通过",
          type: "success",
        });
        this.dialogVisible = false;
        this.fetchData();
      });
    },
    checkInfo(id) {
      this.dialogVisible = true;
      api.findrealById(id).then((response) => {
        this.loanList = response.data;
        console.log(this.loanList);
      });
    },
    resetData() {
      // 1.清空条件搜索
      this.searchObj = {};
      //2.清空日期条件
      this.createTimes = [];
      //3.刷新数据列表
      this.fetchData();
    },
    fetchData(page = 1) {
      this.page = page;
      if (this.createTimes && this.createTimes.length == 2) {
        this.searchObj.createTimeBegin = this.createTimes[0];
        this.searchObj.createTimeEnd = this.createTimes[1];
      }
      api.getrealauthList(this.page, this.limit, this.searchObj).then(response => {
        //this.list = response.data.list
        this.list = response.data.records;
        this.total = response.data.total;
        // 数据加载并绑定成功
        this.listLoading = false;
        console.log(response.data.records);
      });
    },
  },
  components: { Image }
}
</script>
  
<style></style>